﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
namespace HOOMT
{
    class StaticSimpleRelationship: OriginalLine
    {
        public StaticSimpleRelationship(Point startPoint, Point endPoint, OriginalDiagram startDiagram, OriginalDiagram endDiagram)
            : base(startPoint, endPoint, startDiagram, endDiagram)
        {
            //LineName = "StaticSimpleRelationship";
        }
        public StaticSimpleRelationship(Point startPoint, Point endPoint, string id, OriginalDiagram startDiagram, OriginalDiagram endDiagram)
            : base(startPoint, endPoint, id, startDiagram, endDiagram)
        {
            //LineName = "StaticSimpleRelationship";
        }
        //***********************************************************************************
        public override void Drawing(Graphics g, OriginalModelForm m)
        {
            Pen pen = new Pen(Color.Brown, 1);
            Point start = GetStartShowPoint();
            Point end = GetEndShowPoint();
            //画箭头
            double flRlt = Math.Sqrt((start.X - end.X) * (start.X - end.X) + (start.Y - end.Y) * (start.Y - end.Y));
            float flength = 10;//箭头长度
            if (flRlt == 0) return;
            double tmpX = end.X + (start.X - end.X) * flength / flRlt;
            double tmpY = end.Y + (start.Y - end.Y) * flength / flRlt;
            double fl1X = (tmpX - end.X) * Math.Sqrt((float)3) / 2 + (tmpY - end.Y) * 1 / 2 + end.X;
            double fl1Y = (tmpY - end.Y) * Math.Sqrt((float)3) / 2 - (tmpX - end.X) * 1 / 2 + end.Y;
            double fl2X = (tmpX - end.X) * Math.Sqrt((float)3) / 2 - (tmpY - end.Y) * 1 / 2 + end.X;
            double fl2Y = (tmpY - end.Y) * Math.Sqrt((float)3) / 2 + (tmpX - end.X) * 1 / 2 + end.Y;
            g.DrawLine(pen, new Point(end.X, end.Y), new Point((int)fl1X, (int)fl1Y));
            g.DrawLine(pen, new Point(end.X, end.Y), new Point((int)fl2X, (int)fl2Y));
            //画直线
            //g.DrawLine(pen, start, end);
            base.Drawing(g, m);
        }
        //***********************************************************************************
        public override bool equalTo(OriginalLine line)
        {
            //判断直线反向相等
            //if (endPoint == line.StartPoint && startPoint == line.EndPoint)
                //return true;
            //判断相等
            return base.equalTo(line);
        }

    }
}
